#ifndef _OCPP_ObliqueStatistic_H_
#define _OCPP_ObliqueStatistic_H_

#include "../osg.h"
#include "../gltfConfig.h"
#include "OCMain/FileUtil.h"

#include "OCesium/Cartographic.h"
#include "OCesium/Ellipsoid.h"
#include "OCesium/Rectangle.h"
#include "OCesium/Transforms.h"
#include "OCesium/EllipsoidGeodesic.h"
#include "OCesium/TilingScheme.h"

namespace OCPP
{
	namespace Cesium
	{
		class ObliqueTileStatistic
		{
		public:
			ObliqueTileStatistic() {}
			Json::Value toJson();
			void fromJson(Json::Value& value);

			void countLevel(uint32 value) {
				if (nodeDepth < value) nodeDepth = value;
			}

			void countGeode(uint32 value) {
				if (maxNumGeodeInNode < value) maxNumGeodeInNode = value;
				numGeode += value;
			}

			void countNumGeodePerLevel(uint32 numGeode, uint32 nodeDepth,osg::BoundingBox& boundingBox1,long numPixels) {
				if (numGeodePerLevel.size() <= nodeDepth)
				{
					numGeodePerLevel.resize(nodeDepth + 1);
				}
				if (numPagedLodPerLevel.size() <= nodeDepth)
				{
					numPagedLodPerLevel.resize(nodeDepth + 1);
				}
				if (numPixelPerLevels.size() <= nodeDepth)
				{
					numPixelPerLevels.resize(nodeDepth + 1);
				}

				numGeodePerLevel[nodeDepth] += numGeode;
				numPagedLodPerLevel[nodeDepth] += 1;
				numPixelPerLevels[nodeDepth] += numPixels;
				
				if (boundingBox1.xMax() - boundingBox1.xMin() > 0.0)
				{
					boundingBox.expandBy(boundingBox1);
				}

				countGeode(numGeode);
				countLevel(nodeDepth);
			}

			LongVector numPixelPerLevels;
			osg::BoundingBox boundingBox;
			uint32 nodeDepth = 0;
			uint32 maxNumGeodeInNode = 0;
			uint32 numGeode = 0;
			IntVector numGeodePerLevel;
			IntVector numPagedLodPerLevel;
			std::map<uint32, uint32> tileLevelMap;
		};
	}
}


#endif
